package com.originskyseed.platform.api.controller;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.originskyseed.platform.core.base.BasePage;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.client.producer.SendStatus;
import org.apache.rocketmq.common.message.Message;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import com.originskyseed.platform.api.i18n.ApiResponseMsg;
import com.originskyseed.platform.api.vo.request.GetAccessTokenRequestVO;
import com.originskyseed.platform.common.api.config.QueryUrlConfig;
import com.originskyseed.platform.core.aspect.annotation.RequiredParams;
import com.originskyseed.platform.core.base.BaseController;
import com.originskyseed.platform.core.base.BaseLocaleResource;
import com.originskyseed.platform.core.base.BaseResponseBody;
import com.originskyseed.platform.core.common.code.CommonResponseCode;
import com.originskyseed.platform.core.config.bean.ConfigManager;
import com.originskyseed.platform.core.rocketmq.api.RocketMQProducer;
import com.originskyseed.platform.core.tenant.util.TenantAuthUtil;
import com.originskyseed.platform.core.tenant.util.TenantCodeUtil;
import com.originskyseed.platform.core.util.bean.PrimaryKeyGeneratorUtil;
import com.originskyseed.platform.log.model.InterfaceSynchroLog;
import com.originskyseed.platform.log.service.IInterfaceSynchroLogService;
import com.originskyseed.platform.user.model.Anchor;
import com.originskyseed.platform.user.model.AnchorRelateAnnex;
import com.originskyseed.platform.user.model.Player;
import com.originskyseed.platform.user.service.IAnchorRelateAnnexService;
import com.originskyseed.platform.user.service.IAnchorService;
import com.originskyseed.platform.user.service.IFamilyService;
import com.originskyseed.platform.user.service.IPlayerService;
import com.originskyseed.platform.user.service.ITradeUnionService;
import com.originskyseed.platform.user.service.IUserInfoService;

@Controller
@RequestMapping("/familyAnchorInsert")
@BaseLocaleResource(localeFileName = "i18n_api")
public class FamilyAnchorInsertController extends BaseController {

    private static final Logger logger = LoggerFactory.getLogger(FamilyAnchorInsertController.class);

    @DubboReference
    private IAnchorService anchorService;

    @DubboReference
    private IFamilyService familyService;

    @DubboReference
    private IPlayerService playerService;

    @DubboReference
    private IUserInfoService userInfoService;

    @DubboReference
    private IAnchorRelateAnnexService anchorRelateAnnexService;

    @DubboReference
    private IInterfaceSynchroLogService iInterfaceSynchroLogService;

    @DubboReference
    private ITradeUnionService tradeUnionService;

    SimpleDateFormat formatTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    /**
     * 新增家族
     *
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
	/*@ResponseBody
	@RequestMapping("/familyInsert.json")
	@RequiredParams(names = { "appkey", "appSecret", "familyList" })
	public BaseResponseBody familyInsert(HttpServletRequest request, HttpServletResponse response) throws Exception {
		// 验证授权键值和授权代码
		BaseResponseBody result = this.verificationKeySecret();
		if (result != null)
			return result;

		// 记录日志
		InterfaceSynchroLog interfaceSynchroLog = new InterfaceSynchroLog();
		interfaceSynchroLog.setStartTime(new Date());
		interfaceSynchroLog.setDesc("同步家族信息");
		interfaceSynchroLog.setName("familyInsert.json");
		interfaceSynchroLog.setType(1);
		try {
			// 接收参数
			List<Family> list = this.getParameterList("familyList", Family.class);
			if (list != null && list.size() > 0) {
				// 新增的家族集合
				List<Family> insertFamily = new ArrayList<>();
				// List<UserInfo> userInfoList = new ArrayList<>();

				// 查询有没有重复的主播 有则去重
				List<String> familyIds = list.stream().map(Family::getFamilyId).collect(Collectors.toList());
				familyIds = this.familyService.selectFamilyIds(familyIds);
				for (Family family : list) {
					// 有重复的则不添加
					boolean isInsert = true;
					for (String id : familyIds) {
						if (family.getFamilyId().equals(id)) {
							isInsert = false;
						}
					}
					if (isInsert) {
						*//*
     * UserInfo userInfo = new UserInfo(); userInfo.setId(PrimaryKeyGeneratorUtil.getInstance().getRandomKey()); userInfo.setAccount(family.getFamilyId()); userInfo.setName(family.getName()); userInfo.setPassword(family.getPassword()); userInfo.setPermissionPassword(family.getPermissionPassword()); userInfo.setIsDel(0); userInfo.setStatus(1); userInfo.setPhone(family.getPhone());
     * userInfo.setCreateTime(new Date());
     *//*
						family.setId(PrimaryKeyGeneratorUtil.getInstance().getRandomKey());
						// family.setUserId(userInfo.getId());
						family.setCreateTime(new Date());
						// userInfoList.add(userInfo);
						insertFamily.add(family);
					}
				}

				// 新增家族 和用户
				if (insertFamily.size() > 0) {
					// 一次性插入的数量
					int size = 500;
					// 总长度
					int userLength = insertFamily.size();
					// 计算可以分成多少组
					int num = (userLength + size - 1) / size;
					for (int i = 0; i < num; i++) {
						// 开始位置
						int fromIndex = i * size;
						// 结束位置
						int toIndex = (i + 1) * size < userLength ? (i + 1) * size : userLength;
						// List<UserInfo> newUserList = userInfoList.subList(fromIndex,toIndex) ;
						// userInfoService.insertBatchUser(newUserList);

						List<Family> newFamilyList = insertFamily.subList(fromIndex, toIndex);
						this.familyService.insertBatchFamily(newFamilyList);
					}
				}
			}
			interfaceSynchroLog.setState(1);
			result = new BaseResponseBody(true, CommonResponseCode.SUCCESS.getCode(), this.getLocaleMessage(this.getClass(), ApiResponseMsg.FAMILY_SAVE_SUCCESS.getMsg()), true);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			result = new BaseResponseBody(false, CommonResponseCode.ERROR.getCode(), this.getLocaleMessage(this.getClass(), ApiResponseMsg.FAMILY_SAVE_ERROR.getMsg()), e.getMessage(), null);

			interfaceSynchroLog.setState(2);
			interfaceSynchroLog.setErrorLog(e.getMessage());
			interfaceSynchroLog.setEndTime(new Date());
			this.iInterfaceSynchroLogService.insertSelective(interfaceSynchroLog);
		}
		return result;

	}*/

    /**
     * 新增主播
     *
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    @ResponseBody
    @RequestMapping("/anchorInsert.json")
    @RequiredParams(names = {"appkey", "appSecret", "anchorList"})
    public BaseResponseBody anchorInsert(HttpServletRequest request, HttpServletResponse response) throws Exception {
        // 验证授权键值和授权代码
        BaseResponseBody result = this.verificationKeySecret();
        if (result != null)
            return result;

        // 开始时间
        long startTime = System.currentTimeMillis();
        // 记录日志
        InterfaceSynchroLog interfaceSynchroLog = new InterfaceSynchroLog();
        interfaceSynchroLog.setStartTime(new Date());
        interfaceSynchroLog.setDesc("同步主播信息");
        interfaceSynchroLog.setName("anchorInsert.json");
        interfaceSynchroLog.setType(1);
        try {
            QueryUrlConfig queryUrlConfig = ConfigManager.getInstance().parseObject(QueryUrlConfig.class);
            // 使用消息队列
            if (queryUrlConfig.getIsUseQueue() != null && queryUrlConfig.getIsUseQueue() == 1) {
                // 获取租户标识
                String tenantCode = TenantCodeUtil.getInstance().getServerTenantCode();
                // 获取参数数据
                String anchorListStr = this.getParameterString("anchorList", "");
                // 封装参数
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("tenantCode", tenantCode);
                jsonObject.put("list", anchorListStr);
                Message message = new Message("synchroData", "push", "anchorInsert", jsonObject.toJSONString().getBytes());
                SendResult sendResult = RocketMQProducer.getInstance().syncSend(message);
                long endTime0 = System.currentTimeMillis();
                //System.out.println("/anchorInsert.json接口调用耗时(sendResult)："+sendResult+"===="+(endTime0-startTime)+"=date=="+formatTime.format(new Date()));
                if (sendResult.getSendStatus() != SendStatus.SEND_OK) {
                    interfaceSynchroLog.setState(3);
                    interfaceSynchroLog.setErrorLog(anchorListStr);
                    interfaceSynchroLog.setEndTime(new Date());
                    this.iInterfaceSynchroLogService.insertSelective(interfaceSynchroLog);
                    return new BaseResponseBody(false, CommonResponseCode.ERROR.getCode(), this.getLocaleMessage(this.getClass(), ApiResponseMsg.SAVE_ERROR.getMsg()), null);
                }

            } else {
                List<Anchor> list = this.getParameterList("anchorList", Anchor.class);
                if (list != null && list.size() > 0) {
                    // 新增的主播集合
                    List<Anchor> insertAnchorList = new ArrayList<>();
                    List<AnchorRelateAnnex> anchorRelateAnnexList = new ArrayList<>();

                    // 查询有没有重复的主播 有则去重
                    List<String> anchorIds = list.stream().map(Anchor::getAnchorId).collect(Collectors.toList());
                    anchorIds = this.anchorService.selectAnchorIds(anchorIds);

                    for (Anchor anchor : list) {
                        boolean isInsert = true;
                        for (String anchorId : anchorIds) {
                            if (anchorId.equals(anchor.getAnchorId())) {
                                isInsert = false;
                            }
                        }
                        if (isInsert) {
                            anchor.setId(PrimaryKeyGeneratorUtil.getInstance().getRandomKey());
                            anchor.setIsDel(0);
                            anchor.setCreateTime(new Date());
                            if (StringUtils.isNotEmpty(anchor.getAnchorMedal())) {
                                AnchorRelateAnnex anchorRelateAnnex = new AnchorRelateAnnex();
                                anchorRelateAnnex.setId(PrimaryKeyGeneratorUtil.getInstance().getRandomKey());
                                anchorRelateAnnex.setAnchorId(anchor.getId());
                                anchorRelateAnnex.setPath(anchor.getAnchorMedal());
                                anchorRelateAnnex.setType(1);
                                anchorRelateAnnexList.add(anchorRelateAnnex);
                            }
                            insertAnchorList.add(anchor);
                        }
                    }

                    // 一次性插入的数量
                    int size = 500;
                    // 新增主播和用户信息
                    if (insertAnchorList.size() > 0) {
                        // 总长度
                        int userLength = insertAnchorList.size();
                        // 计算可以分成多少组
                        int num = (userLength + size - 1) / size;
                        for (int i = 0; i < num; i++) {
                            // 开始位置
                            int fromIndex = i * size;
                            // 结束位置
                            int toIndex = (i + 1) * size < userLength ? (i + 1) * size : userLength;
                            List<Anchor> newAnchorList = insertAnchorList.subList(fromIndex, toIndex);
                            this.anchorService.insertBatchAnchor(newAnchorList);
                        }
                    }

                    // 新增主播附件信息
                    if (anchorRelateAnnexList.size() > 0) {
                        // 总长度
                        int length = anchorRelateAnnexList.size();
                        // 计算可以分成多少组
                        int num = (length + size - 1) / size;
                        for (int i = 0; i < num; i++) {
                            // 开始位置
                            int fromIndex = i * size;
                            // 结束位置
                            int toIndex = (i + 1) * size < length ? (i + 1) * size : length;
                            List<AnchorRelateAnnex> newAnchorRelateAnnex = anchorRelateAnnexList.subList(fromIndex, toIndex);
                            anchorRelateAnnexService.insertBatch(newAnchorRelateAnnex);
                        }
                    }
                }
            }
            //结束时间
            long endTime = System.currentTimeMillis();
            //System.out.println("/anchorInsert.json接口调用耗时："+(endTime-startTime)+"=date=="+formatTime.format(new Date()));
            result = new BaseResponseBody(true, CommonResponseCode.SUCCESS.getCode(), this.getLocaleMessage(this.getClass(), ApiResponseMsg.ANCHOR_SAVE_SUCCESS.getMsg()), true);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            result = new BaseResponseBody(false, CommonResponseCode.ERROR.getCode(), this.getLocaleMessage(this.getClass(), ApiResponseMsg.ANCHOR_SAVE_ERROR.getMsg()), e.getMessage(), null);

            interfaceSynchroLog.setState(2);
            interfaceSynchroLog.setErrorLog(e.getMessage());
            interfaceSynchroLog.setEndTime(new Date());
            this.iInterfaceSynchroLogService.insertSelective(interfaceSynchroLog);
        }
        return result;
    }

    /**
     * 新增玩家
     *
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    @ResponseBody
    @RequestMapping("/playerInsert.json")
    @RequiredParams(names = {"appkey", "appSecret", "playerList"})
    public BaseResponseBody playerInsert(HttpServletRequest request, HttpServletResponse response) throws Exception {
        // 验证授权键值和授权代码
        BaseResponseBody result = this.verificationKeySecret();
        if (result != null)
            return result;

        // 开始时间
        long startTime = System.currentTimeMillis();
        // 记录日志
        InterfaceSynchroLog interfaceSynchroLog = new InterfaceSynchroLog();
        interfaceSynchroLog.setStartTime(new Date());
        interfaceSynchroLog.setDesc("同步玩家信息");
        interfaceSynchroLog.setName("playerInsert.json");
        interfaceSynchroLog.setType(1);
        try {
            QueryUrlConfig queryUrlConfig = ConfigManager.getInstance().parseObject(QueryUrlConfig.class);
            // 使用消息队列
            if (queryUrlConfig.getIsUseQueue() != null && queryUrlConfig.getIsUseQueue() == 1) {
                // 获取租户标识
                String tenantCode = TenantCodeUtil.getInstance().getServerTenantCode();
                // 获取参数数据
                String playerListStr = this.getParameterString("playerList", "");
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("tenantCode", tenantCode);
                jsonObject.put("list", playerListStr);
                Message message = new Message("synchroData", "push", "playerInsert", jsonObject.toJSONString().getBytes());
                SendResult sendResult = RocketMQProducer.getInstance().syncSend(message);
                long endTime0 = System.currentTimeMillis();
                //System.out.println("/playerInsert.json接口调用耗时(sendResult)："+sendResult+"===="+(endTime0-startTime)+"=date=="+formatTime.format(new Date()));
                if (sendResult.getSendStatus() != SendStatus.SEND_OK) {
                    interfaceSynchroLog.setState(3);
                    interfaceSynchroLog.setErrorLog(playerListStr);
                    interfaceSynchroLog.setEndTime(new Date());
                    this.iInterfaceSynchroLogService.insertSelective(interfaceSynchroLog);
                    return new BaseResponseBody(false, CommonResponseCode.ERROR.getCode(), this.getLocaleMessage(this.getClass(), ApiResponseMsg.SAVE_ERROR.getMsg()), null);
                }
            } else {
                // 接收参数
                List<Player> list = this.getParameterList("playerList", Player.class);
                if (list != null && list.size() > 0) {
                    // 新增的玩家集合
                    List<Player> insertPlayer = new ArrayList<>();
                    // 查询有没有重复的玩家 有则去重
                    List<String> playerIds = list.stream().map(Player::getPlayerId).collect(Collectors.toList());
                    playerIds = this.playerService.selectPlayerIds(playerIds);
                    for (Player player : list) {
                        boolean isInsert = true;
                        for (String id : playerIds) {
                            if (player.getPlayerId().equals(id)) {
                                isInsert = false;
                            }
                        }
                        if (isInsert) {
                            player.setBelongBusinessId(player.getChannelSubId());
                            player.setId(PrimaryKeyGeneratorUtil.getInstance().getRandomKey());
                            player.setCreateTime(new Date());
                            insertPlayer.add(player);
                        }
                    }
                    // 新增玩家 和用户
                    if (insertPlayer.size() > 0) {
                        // 一次性插入的数量
                        int size = 500;
                        // 总长度
                        int userLength = insertPlayer.size();
                        // 计算可以分成多少组
                        int num = (userLength + size - 1) / size;
                        for (int i = 0; i < num; i++) {
                            // 开始位置
                            int fromIndex = i * size;
                            // 结束位置
                            int toIndex = (i + 1) * size < userLength ? (i + 1) * size : userLength;

                            List<Player> newPlayerList = insertPlayer.subList(fromIndex, toIndex);
                            this.playerService.insertBatch(newPlayerList);
                        }
                    }
                }
            }

            //结束时间
            long endTime = System.currentTimeMillis();
            //System.out.println("/playerInsert.json接口调用耗时："+(endTime-startTime)+"=date=="+formatTime.format(new Date()));
            result = new BaseResponseBody(true, CommonResponseCode.SUCCESS.getCode(), this.getLocaleMessage(this.getClass(), ApiResponseMsg.SAVE_SUCCESS.getMsg()), true);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            result = new BaseResponseBody(false, CommonResponseCode.ERROR.getCode(), this.getLocaleMessage(this.getClass(), ApiResponseMsg.SAVE_ERROR.getMsg()), e.getMessage(), null);

            interfaceSynchroLog.setState(2);
            interfaceSynchroLog.setErrorLog(e.getMessage());
            interfaceSynchroLog.setEndTime(new Date());
            this.iInterfaceSynchroLogService.insertSelective(interfaceSynchroLog);
        }
        return result;

    }


    /**
     * 新增玩家
     *
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    @ResponseBody
    @RequestMapping("/playerInsertTest.json")
    @RequiredParams(names = {"appkey", "appSecret", "playerList"})
    public BaseResponseBody playerInsertTest(HttpServletRequest request, HttpServletResponse response) throws Exception {
        // 验证授权键值和授权代码
        BaseResponseBody result = this.verificationKeySecret();
        if (result != null)
            return result;

        // 开始时间
        long startTime = System.currentTimeMillis();
        // 记录日志
        InterfaceSynchroLog interfaceSynchroLog = new InterfaceSynchroLog();
        interfaceSynchroLog.setStartTime(new Date());
        interfaceSynchroLog.setDesc("同步玩家信息");
        interfaceSynchroLog.setName("playerInsert.json");
        interfaceSynchroLog.setType(1);
        try {
            QueryUrlConfig queryUrlConfig = ConfigManager.getInstance().parseObject(QueryUrlConfig.class);
            // 使用消息队列
            if (queryUrlConfig.getIsUseQueue() != null && queryUrlConfig.getIsUseQueue() == 1) {
                // 获取租户标识
                String tenantCode = TenantCodeUtil.getInstance().getServerTenantCode();
                // 获取参数数据
                String playerListStr = this.getParameterString("playerList", "");

                long endTime0 = System.currentTimeMillis();
                System.out.println("/playerInsertTest.json接口调用耗时(sendResult)："  + "====" + (endTime0 - startTime) + "=date==" + formatTime.format(new Date()));
            }
            //结束时间
            long endTime = System.currentTimeMillis();
            System.out.println("/playerInsertTest.json接口调用耗时："+(endTime-startTime)+"=date=="+formatTime.format(new Date()));
            result = new BaseResponseBody(true, CommonResponseCode.SUCCESS.getCode(), this.getLocaleMessage(this.getClass(), ApiResponseMsg.SAVE_SUCCESS.getMsg()), true);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            result = new BaseResponseBody(false, CommonResponseCode.ERROR.getCode(), this.getLocaleMessage(this.getClass(), ApiResponseMsg.SAVE_ERROR.getMsg()), e.getMessage(), null);

            interfaceSynchroLog.setState(2);
            interfaceSynchroLog.setErrorLog(e.getMessage());
            interfaceSynchroLog.setEndTime(new Date());
            this.iInterfaceSynchroLogService.insertSelective(interfaceSynchroLog);
        }
        return result;

    }


    /**
     * 新增玩家
     *
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    @ResponseBody
    @RequestMapping("/playerInsertTest1.json")
    @RequiredParams(names = {"appkey", "appSecret"})
    public BaseResponseBody playerInsertTest1(HttpServletRequest request, HttpServletResponse response) throws Exception {
        // 验证授权键值和授权代码
        //BaseResponseBody result = this.verificationKeySecret();
        BaseResponseBody result = null;
        try {
            long startTime = System.currentTimeMillis();
            //结束时间
            long endTime = System.currentTimeMillis();
            System.out.println("/playerInsertTest.json接口调用耗时："+(endTime-startTime)+"=date=="+formatTime.format(new Date()));
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
        }
        return result;

    }
    /**
     * 新增工会
     *
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
	/*@ResponseBody
	@RequestMapping("/tradeUnionInsert.json")
	@RequiredParams(names = { "appkey", "appSecret", "tradeUnionList" })
	public BaseResponseBody tradeUnionInsert(HttpServletRequest request, HttpServletResponse response) throws Exception {
		// 验证授权键值和授权代码
		BaseResponseBody result = this.verificationKeySecret();
		if (result != null)
			return result;
		// 记录日志
		InterfaceSynchroLog interfaceSynchroLog = new InterfaceSynchroLog();
		interfaceSynchroLog.setStartTime(new Date());
		interfaceSynchroLog.setDesc("同步工会信息");
		interfaceSynchroLog.setName("tradeUnionInsert.json");
		interfaceSynchroLog.setType(1);
		try {
			// 接收参数
			List<TradeUnion> list = this.getParameterList("tradeUnionList", TradeUnion.class);
			if (list != null && list.size() > 0) {
				// 新增的玩家集合
				List<TradeUnion> insertTradeUnionList = new ArrayList<>();

				// 查询有没有重复的玩家 有则去重
				List<String> tradeUnionIds = list.stream().map(TradeUnion::getTradeUnionId).collect(Collectors.toList());
				tradeUnionIds = this.tradeUnionService.selectTradeUnionIds(tradeUnionIds);
				for (TradeUnion tradeUnion : list) {
					boolean isInsert = true;
					for (String id : tradeUnionIds) {
						if (tradeUnion.getTradeUnionId().equals(id)) {
							isInsert = false;
						}
					}
					if (isInsert) {
						tradeUnion.setId(PrimaryKeyGeneratorUtil.getInstance().getRandomKey());
						tradeUnion.setCreateTime(new Date());

						insertTradeUnionList.add(tradeUnion);
					}
				}

				// 新增玩家 和用户
				if (insertTradeUnionList.size() > 0) {
					// 一次性插入的数量
					int size = 500;
					// 总长度
					int userLength = insertTradeUnionList.size();
					// 计算可以分成多少组
					int num = (userLength + size - 1) / size;
					for (int i = 0; i < num; i++) {
						// 开始位置
						int fromIndex = i * size;
						// 结束位置
						int toIndex = (i + 1) * size < userLength ? (i + 1) * size : userLength;

						List<TradeUnion> newTradeUnionList = insertTradeUnionList.subList(fromIndex, toIndex);
						this.tradeUnionService.insertBatch(newTradeUnionList);
					}
				}
			}
			interfaceSynchroLog.setState(1);
			result = new BaseResponseBody(true, CommonResponseCode.SUCCESS.getCode(), this.getLocaleMessage(this.getClass(), ApiResponseMsg.SAVE_SUCCESS.getMsg()), true);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			result = new BaseResponseBody(false, CommonResponseCode.ERROR.getCode(), this.getLocaleMessage(this.getClass(), ApiResponseMsg.SAVE_ERROR.getMsg()), e.getMessage(), null);

			interfaceSynchroLog.setState(2);
			interfaceSynchroLog.setErrorLog(e.getMessage());
			interfaceSynchroLog.setEndTime(new Date());
			this.iInterfaceSynchroLogService.insertSelective(interfaceSynchroLog);
		}
		return result;

	}*/

    /**
     * 验证授权键值和授权代码
     *
     * @return
     */
    private BaseResponseBody verificationKeySecret() {
        // 请求对象
        GetAccessTokenRequestVO requestVO = this.getParameterBean(GetAccessTokenRequestVO.class);
        // 获取第三方授权返回码
        int responseCode = TenantAuthUtil.getInstance().getAuthenticatedResponseCode(requestVO.getAppkey(), requestVO.getAppSecret());
        if (responseCode == 2004) {
            return null;
        } else {
            return new BaseResponseBody(false, CommonResponseCode.ERROR.getCode(), this.getLocaleMessage(this.getClass(), ApiResponseMsg.APP_KEY_APP_SECRET_ERROR.getMsg()), false);
        }
    }
}
